package com.chz.SupermarketMS.dao;


//import com.chz.SupermarketMS.dto.CommodityPDetails;
import com.chz.SupermarketMS.dto.KindCommodities;
import com.chz.SupermarketMS.entities.Commodity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

//CRUD(增删改查)
@Repository
public interface CommodityRepository extends CrudRepository<Commodity, Long> {

    @Override
    List<Commodity> findAll();

    Commodity findByCommodityId(long theId);

    @Query(nativeQuery = true,value = "SELECT c.commodity_id as commodityId, c.name, k.type as kind, c.date,  c.number, c.price " +
             "FROM chz.commodity c left join chz.kind k on c.kind_id = k.kind_id;"
    )
    List<KindCommodities> kindCommodities();

}
